<template>
    <div class="pegination">
        <el-pagination
            background
            :current-page="currentPage"
            :page-sizes="[20, 50, 100]"
            :page-size="currentSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
        >
        </el-pagination>
    </div>
</template>

<script>
    export default {
        name: 'BlogPagination',
        props: {
            total: {
                type: Number,
                default: 0
            }
        },
        data () {
            return {
                currentPage: 1,
                currentSize: 20
            };
        },
        methods: {
            handleSizeChange (size) {
                this.currentSize = size;
                this.$emit('on-size-change', this.currentSize);
            },
            handleCurrentChange (page) {
                this.currentPage = page;
                this.$emit('on-page-change', this.currentPage);
            }
        }
    };
</script>

<style lang="less" scoped>
.pegination {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}
</style>
